/*
 * Copyright 2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as React from "react"
import { lazy, Suspense } from "react"
import { Route } from "react-router"


class App extends React.Component {

  public render() {
    return (
      <div style={{
        position: "fixed",
        height: "100%",
        width: "100%",
        top: 0,
      }}>
        <Suspense fallback={<div>loading...</div>}>
          <Route exact path="/" component={lazy(() => import("./pages/FirstPage"))}/>
          <Route
            path="/search"
            component={lazy(() => import("./search"))}/>
          <Route exact path="/categories" component={lazy(() => import("./pages/FirstPage"))}/>
          <Route exact path="/cart" component={lazy(() => import("./pages/FirstPage"))}/>
          <Route exact path="/my-center" component={lazy(() => import("./pages/FirstPage"))}/>
          <Route path="/products/:id" component={lazy(() => import("./product/product-detail"))}/>
          <Route path="/stores/:id" component={lazy(() => import("./storefront"))}/>
          <Route path="/orders/fill" component={lazy(() => import("./order/fill-order"))}/>
          <Route path="/orders/payments" component={lazy(() => import("./order/order-payments"))}/>
          <Route path="/orders" component={lazy(() => import("./order/order-list"))}/>
          <Route path="/order-details/:order_id" component={lazy(() => import("./order/order-detail"))}/>
          <Route path="/customers/:customer_id/settings" component={lazy(() => import("./customer/setting"))}/>
          <Route exact path="/customers/:customer_id/addresses"
                 component={lazy(() => import("./customer/shipping-addresses"))}/>
          <Route
            path="/customers/:customer_id/addresses/new"
            component={lazy(() => import("./customer/shipping-address-new"))}/>
          <Route
            path="/customers/:customer_id/addresses/:address_id/edit"
            component={lazy(() => import("./customer/shipping-address-edit"))}/>
          <Route
            path="/customers/:customer_id/follow-products"
            component={lazy(() => import("./follow/follow-products"))}/>
          <Route
            path="/customers/:customer_id/follow-stores"
            component={lazy(() => import("./follow/follow-stores"))}/>
          <Route
            path="/customers/:customer_id/browsing-products"
            component={lazy(() => import("./customer/browsing-products"))}/>
          <Route
            exact
            path="/login"
            component={lazy(() => import("./pages/login"))}/>
          <Route
            exact
            path="/captcha"
            component={lazy(() => import("./pages/captcha"))}/>
          <Route
            path="/register"
            component={lazy(() => import("./pages/register"))}/>
        </Suspense>
      </div>
    )
  }
}

export default App
